home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / pminfo / pminfo.bas < prev    next >
BASIC Source File  |  1995-05-09  |  8KB  |  281 lines

  1. Global Const ProgTitle = "Steve's ProgMan Info"
  2.  
  3. Type GroupHeader
  4.   Name As String
  5.   NumItems As Integer
  6. End Type
  7.  
  8. Type GroupInfo
  9.   Parent As Integer
  10.   Name As String
  11.   CommandLine As String
  12.   DefaultDir As String
  13.   IconPath As String
  14.   MinFlag As Integer
  15. End Type
  16.  
  17. Type MasterGroup
  18.   Name As String
  19.   Level As Integer
  20. End Type
  21.  
  22. Global GroupList() As GroupHeader
  23. Global GroupInfoList() As GroupInfo
  24. Global MasterList() As MasterGroup
  25.  
  26. 'Word 6 document name
  27. Global Const DOC_NAME = "PMINFO.DOC"
  28.  
  29. 'Word 6 document object
  30. Global OhMyWord As Object
  31.  
  32. 'window state
  33. Global Const WINDOW_MINIMIZED = 1
  34.  
  35. 'dde link
  36. Global Const COLD_LINK = 2
  37.  
  38. 'dialog box stuff
  39. Global Const YES_NO_QUESTION = 36
  40. Global Const NO = 7
  41.  
  42. Sub CenterForm (SForm As Form)
  43.  
  44. SForm.Top = (Screen.Height - SForm.Height) / 2
  45. SForm.Left = (Screen.Width - SForm.Width) / 2
  46.  
  47. End Sub
  48.  
  49. Function FillGroupInfoList (GroupNum As Integer) As Integer
  50.  
  51. Dim FirstPos As Integer
  52. Dim NextPos As Integer
  53. Dim Looper As Integer
  54. Dim MyText As String
  55. Dim Minimized As Integer
  56.  
  57. On Error GoTo FillGroupInfoError
  58.  
  59. 'set initial value
  60. FillGroupInfoList = False
  61.  
  62. 'get the text from the text box
  63. MyText = PMMainForm.DDEText.Text
  64.  
  65. 'find the first comma (chr$(44) is a comma)
  66. FirstPos = InStr(1, MyText, Chr$(44))
  67.  
  68. 'find the next comma
  69. FirstPos = InStr(FirstPos + 1, MyText, Chr$(44))
  70. 'find the third comma
  71. NextPos = InStr(FirstPos + 1, MyText, Chr$(44))
  72.  
  73. 'get the number of group items; start from the character after the 2nd comma, and
  74. 'take the number of characters up to but not including the third comma
  75. GroupList(GroupNum).NumItems = Val(Mid$(MyText, FirstPos + 1, NextPos - FirstPos - 1))
  76.  
  77. 'find the start of the second line, after the first set of quote marks
  78. FirstPos = InStr(1, MyText, Chr$(10)) + 2
  79.  
  80. 'iterate through the number of items for this group
  81. For Looper = 1 To GroupList(GroupNum).NumItems
  82.   'bump our group info array by one
  83.   ReDim Preserve GroupInfoList(UBound(GroupInfoList) + 1)
  84.   
  85.   'set the group parent
  86.   GroupInfoList(UBound(GroupInfoList)).Parent = GroupNum
  87.  
  88.   'find the trailing quote of the icon name
  89.   NextPos = InStr(FirstPos, MyText, Chr$(34))
  90.  
  91.   'add the icon name to the group info array
  92.   GroupInfoList(UBound(GroupInfoList)).Name = Mid$(MyText, FirstPos, NextPos - FirstPos)
  93.  
  94.   'set the new starting position - the last quote, plus the comma, plus the next quote
  95.   FirstPos = NextPos + 3
  96.  
  97.   'find the trailing quote of the command line
  98.   NextPos = InStr(FirstPos, MyText, Chr$(34))
  99.  
  100.   'add the command line info to the array
  101.   GroupInfoList(UBound(GroupInfoList)).CommandLine = Mid$(MyText, FirstPos, NextPos - FirstPos)
  102.  
  103.   'set the new starting postion - the last quote, plus the comma
  104.   FirstPos = NextPos + 2
  105.  
  106.   'find the next comma
  107.   NextPos = InStr(FirstPos, MyText, Chr$(44))
  108.  
  109.   'add the default directory information to the array
  110.   GroupInfoList(UBound(GroupInfoList)).DefaultDir = Mid$(MyText, FirstPos, NextPos - FirstPos)
  111.  
  112.   'set the new starting position - the last comma, plus one
  113.   FirstPos = NextPos + 1
  114.  
  115.   'find the next comma
  116.   NextPos = InStr(FirstPos, MyText, Chr$(44))
  117.   
  118.   'add the icon path to the array
  119.   GroupInfoList(UBound(GroupInfoList)).IconPath = Mid$(MyText, FirstPos, NextPos - FirstPos)
  120.  
  121.   'find the end of the line
  122.   FirstPos = InStr(NextPos, MyText, Chr$(13))
  123.  
  124.   'set the minimize flag
  125.   Minimized = Val(Mid$(MyText, FirstPos - 1, 1))
  126.  
  127.   If Minimized = 0 Then
  128.     GroupInfoList(UBound(GroupInfoList)).MinFlag = False
  129.   Else
  130.     GroupInfoList(UBound(GroupInfoList)).MinFlag = True
  131.   End If
  132.  
  133.   'set the starting position to the beginning of the next line
  134.   FirstPos = FirstPos + 3
  135.  
  136. Next Looper
  137.  
  138. 'return success!
  139. FillGroupInfoList = True
  140.  
  141. FillGroupInfoResume:
  142. Exit Function
  143.  
  144. FillGroupInfoError:
  145. Resume FillGroupInfoResume
  146.  
  147. End Function
  148.  
  149. Function FillGroupList () As Integer
  150.  
  151. On Error GoTo FillGroupListError
  152.  
  153. Dim Looper As Integer
  154. Dim MyString As String
  155. Dim TempStr As String
  156.  
  157. 'set initial value
  158. FillGroupList = False
  159.  
  160. 'reset our array
  161. ReDim GroupList(0)
  162.  
  163. 'get text
  164. MyString = PMMainForm.DDEText.Text
  165.  
  166. 'for each character in the  string
  167. For Looper = 1 To Len(MyString)
  168.   
  169.   If Asc(Mid$(MyString, Looper, 1)) > 31 Then  'if we don't have a non-printable character
  170.     TempStr = TempStr + Mid$(MyString, Looper, 1)  'concatenate string
  171.   Else
  172.     
  173.     If TempStr <> "" Then  'we've formed a group name
  174.       ReDim Preserve GroupList(UBound(GroupList) + 1)  'bump our array by one
  175.       GroupList(UBound(GroupList)).Name = TempStr  'add the group name to the array
  176.       TempStr = ""                            'clear out our list
  177.     End If
  178.  
  179.   End If
  180.  
  181. Next Looper
  182.  
  183. 'return success!
  184. FillGroupList = True
  185.  
  186. FillGroupListResume:
  187. Exit Function
  188.  
  189. FillGroupListError:
  190. Resume FillGroupListResume
  191.  
  192. End Function
  193.  
  194. Function FillMasterList () As Integer
  195.  
  196. Dim Looper As Integer
  197. Dim Loop2 As Integer
  198. Dim CurItem As Integer
  199.  
  200. On Error GoTo FillMasterListError
  201.  
  202. 'initialize variables
  203. FillMasterList = False
  204. ReDim MasterList(0)
  205. CurItem = 1
  206.  
  207. For Looper = 1 To UBound(GroupList)
  208.  
  209.   ReDim Preserve MasterList(UBound(MasterList) + 1)  'increment our array
  210.   MasterList(UBound(MasterList)).Name = GroupList(Looper).Name 'add the group name
  211.   MasterList(UBound(MasterList)).Level = 1  'add the level
  212.  
  213.   'loop through each group's individual items
  214.   For Loop2 = CurItem To GroupList(Looper).NumItems + CurItem - 1
  215.  
  216.       ReDim Preserve MasterList(UBound(MasterList) + 1)  'increment our array
  217.       MasterList(UBound(MasterList)).Name = GroupInfoList(Loop2).Name  'add the icon name
  218.       MasterList(UBound(MasterList)).Level = 2  'add the level
  219.       
  220.       ReDim Preserve MasterList(UBound(MasterList) + 1)  'increment our array
  221.       MasterList(UBound(MasterList)).Name = "Command Line:  " + GroupInfoList(Loop2).CommandLine'add the command line
  222.       MasterList(UBound(MasterList)).Level = 3  'add the level
  223.  
  224.       ReDim Preserve MasterList(UBound(MasterList) + 1)  'increment our array
  225.       MasterList(UBound(MasterList)).Name = "Default Directory:  " + GroupInfoList(Loop2).DefaultDir'add the default directory
  226.       MasterList(UBound(MasterList)).Level = 3  'add the level
  227.  
  228.       ReDim Preserve MasterList(UBound(MasterList) + 1)  'increment our array
  229.       MasterList(UBound(MasterList)).Name = "Icon Path:  " + GroupInfoList(Loop2).IconPath'add the icon path
  230.       MasterList(UBound(MasterList)).Level = 3  'add the level
  231.  
  232.       ReDim Preserve MasterList(UBound(MasterList) + 1)  'increment our array
  233.       
  234.       If GroupInfoList(Loop2).MinFlag Then
  235.         MasterList(UBound(MasterList)).Name = "Minimize Flag:  True"
  236.       Else
  237.         MasterList(UBound(MasterList)).Name = "Minimize Flag:  False"
  238.       End If
  239.  
  240.       MasterList(UBound(MasterList)).Level = 3  'add the level
  241.  
  242.   Next Loop2
  243.  
  244. 'increment the number of items we've worked with
  245. CurItem = CurItem + GroupList(Looper).NumItems
  246.  
  247. Next Looper
  248.  
  249. 'clear out our other arrays to clean up some memory
  250. ReDim GroupList(0)
  251. ReDim GroupInfoList(0)
  252.  
  253. 'return success!
  254. FillMasterList = True
  255.  
  256. FillMasterListResume:
  257. Exit Function
  258.  
  259. FillMasterListError:
  260. Resume FillMasterListResume
  261.  
  262. End Function
  263.  
  264. Sub FillPMOutline ()
  265.  
  266. Dim MyOutline As Control
  267.  
  268. 'set our object to the outline to make it easier (and quicker) to reference
  269. Set MyOutline = PMMainForm.PMOutline
  270.  
  271. 'go through each item in the master list and add it to the outline
  272. For Looper = 1 To UBound(MasterList)
  273.   MyOutline.AddItem MasterList(Looper).Name, Looper + 1
  274.   MyOutline.Indent(Looper + 1) = MasterList(Looper).Level
  275. Next Looper
  276.  
  277. Set MyOutline = Nothing
  278.  
  279. End Sub
  280.  
  281.